//
//  DXCoupon.m
//  suremodv
//
//  Created by dd on 13-10-27.
//  Copyright (c) 2013年 xiaomuzhi. All rights reserved.
//

#import "DXCoupon.h"

@implementation DXCoupon

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = [DX colorGray];
        
        _bg = [[UIImageView alloc] initWithFrame:CGRectMake(30.5, 16, 50, 45)];
        _bg.image = [UIImage imageNamed:@"coupon_bg_0"];
        [self addSubview:_bg];
        
        _titleLabel.frame = CGRectMake(0, 66, 106, 20);
        
        _numLabel = [[UILabel alloc] initWithFrame:CGRectMake(31.5, 17, 43, 43)];
        _numLabel.backgroundColor = [UIColor clearColor];
        _numLabel.font = [UIFont boldSystemFontOfSize:20];
        _numLabel.textColor = [DX colorWhite];
        _numLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_numLabel];
        
        _bg.userInteractionEnabled = NO;
        _numLabel.userInteractionEnabled = NO;
        _titleLabel.userInteractionEnabled = NO;
        
        [self setBackgroundImage:[UIImage imageNamed:@"btn_hover_light"] forState:UIControlStateHighlighted];
        
        self.clipsToBounds = YES;
        
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

- (void)setType:(int)type number: (int)num
{
    if (num > 99) num = 99;
    
    _numLabel.text = [DX integer2String:num];
    
    if (type > 4 || type < 0) type = 0;
    _bg.image = [UIImage imageNamed:[NSString stringWithFormat:@"coupon_bg_%d", type]];
}

- (void)setType:(int)type content:(NSString *)content
{
    _numLabel.text = content;
    
    if (type > 4 || type < 0) type = 0;
    _bg.image = [UIImage imageNamed:[NSString stringWithFormat:@"coupon_bg_%d", type]];
}

@end
